<?php
// 1.获取连接
$conn = mysqli_connect("localhost:3306","root","","php");
if(!$conn){
    $msg = "获取数据库连接失败:" . mysqli_connect_error();
    die($msg);// 退出当前脚本执行
}
// 设置连接字符集
mysqli_query($conn, "set names utf8");
// 2.执行sql
$price = 12.5;
$unit = "箱";
$id = 3;

// 修改
$sql = "update t_product "
     ." set p_price = $price, "
     ." p_unit = '$unit' "
     ." where p_id = $id";

// 删除
$id = 4;
$sql = "delete from t_product where p_id = $id";

echo $sql;
echo "<br>";
$result = mysqli_query($conn, $sql);
// 3.处理结果
if($result){
    echo "<h2>执行成功</h2>";
} else {
    echo "执行失败:" . mysqli_error($conn);
    echo "<br>";
}
// 4.关闭连接
mysqli_close($conn);
?>